/**
 * 
 */
package infocluster.resource;

import java.io.IOException;
import java.net.URL;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;

/**
 * @author 08302010017 Xi Qi
 *
 */
public class ResourceLocator {
	
	public static ResourceLocator rl = null;
	
	private ResourceLocator(){}
	
	public static ResourceLocator get(){
		if(rl == null)			
			rl = new ResourceLocator();
		return rl;
	}

	public Image getImage(Shell shell, String path) throws IOException 
	{
	    URL imgURL = getClass().getResource(path);
	    if (imgURL != null) {
	    	//ImageData id = new ImageData();
	    	Image i = new Image(shell.getDisplay(),imgURL.openStream());
	    	return i;
	    } else {
	        System.err.println("Couldn't find file: " + path);
	        return null;
	    }
	}
}
